<template>
  <div class="approval">
    <el-card class="box-card" style="margin-bottom: 10px;">
      <div class="head-title2">
          <div class="title">{{$t('approvalDetail.repaymentRecord')}}</div>
        </div>
      <div style="padding-left: 12px;">  
        <el-table :data="tableData" border stripe style="width: 100%;margin-top: 10px;">
          <!-- 上传时间 -->
          <el-table-column
            header-align="center"
            align="center"
            prop="crtTime"
            :label="$t('AppVersion.uploadTime')"
            width="156"
          ></el-table-column>
          <!-- 凭证图片 -->
          <el-table-column
            header-align="center"
            align="center"
            prop="imagePath"
            :label="$t('approvalDetail.certificateImage')"
            width="200"
          >
            <template slot-scope="scope">
              <el-button type="text" @click.native="handleView(scope.row)">{{$t('approvalDetail.hitsee')}}<i class="el-icon-view el-icon--right"></i> </el-button>
            </template>
          </el-table-column>
          <!-- 备注说明 -->
          <el-table-column
            header-align="center"
            align="center"
            :label="$t('approvalDetail.remark')"
            prop="imageRemark"
          ></el-table-column>
        </el-table>
      </div>
    </el-card>
    <el-dialog :visible.sync="dialogVisibility" width="40%" :before-close="handleClose">
      <div>
        <img :src="currentDialogData.url" style="width:100%;max-height:450px;margin:0 auto;" alt="">
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import SUPPLEIMG from 'assets/images/default-supple.jpg'
import { getRepayImage } from 'api/AuditReport/apprAchiCount/index'
// import { userAllOrderByChannel, getApprovalRemark } from "api/trust/firstApprDetails/index";
export default {
  data() {
    return {
      listObj: {},
      listQuery: {
        orderId: ''
      },
      tableData: [],
      dialogVisibility: false,
      currentDialogData: {
        url: ''
      }
    };
  },
  computed: {
    ...mapGetters(['elements', 'language', 'apprAchiCountDetails'])
  },
  created() {
    this.getParamsDetail();
    // this.getUserInfoAll();
    this.getRepaymentRecord()
  },
  methods: {
    getParamsDetail() {
      this.listObj = this.apprAchiCountDetails;
    },
    // 查看还款记录
    handleView(row) {
      if (row.imagePath) {
        // const protocol = location.protocol
        // const host = '47.92.143.84'
        // const host = location.host
        // const port = location.port
        const absUrl = row.imagePath
        const img = new Image()
        img.src = absUrl
        img.onerror = () => {
          this.currentDialogData.url = SUPPLEIMG
          this.dialogVisibility = true
        }
        this.currentDialogData.url = absUrl
        this.dialogVisibility = true
      }
    },
    handleClose(done) {
      done()
      this.currentDialogData.url = ''
    },
    // 还款凭证上传记录
    getRepaymentRecord() {
      this.listQuery.orderId = this.listObj.orderId
      if (this.listQuery.orderId !== '') {
        getRepayImage(this.listQuery.orderId).then(res => {
          if (res.status === 200 && res.data) {
            this.tableData = []
            this.tableData.push(res.data)
          }
        })
      }
    }
  }
};
</script>

<style scoped lang='scss'>
.title {
  line-height: 22px;
  font-size: 16px;
  display: flex;
  align-items: center;
  font-weight: bold;
  font-weight: bold;
}
.title:before {
  display: block;
  content: "";
  width: 3px;
  height: 16px;
  background-color: #309afe;
}
.title:before {
  margin-right: 8px;
}
::before {
  box-sizing: inherit;
  -webkit-tap-highlight-color: transparent;
}
.menu-title {
  width: 100%;
  box-sizing: border-box;
  background: #ffffff;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  .searchItem {
    display: flex;
    align-items: center;
    padding: 10px 0;
    span {
      display: inline-block;
      width: 100px;
      text-align: right;
      font-size: 12px;
      color: #5f5f61;
      padding-right: 5px;
    }
    div:nth-child(2) {
      width: 150px;
    }
  }
  .searchItem-date {
    display: flex;
    align-items: center;
    padding: 10px 0;
    b {
      margin: 0 10px;
      font-weight: normal;
      font-size: 12px;
      color: #5f5f61;
    }
    div {
      width: 150px;
    }
  }
}
.menu-title-btn {
  padding: 10px 0;
  box-sizing: border-box;
  button {
    padding: 0 20px;
    height: 28px;
    background: #20a0ff;
    color: #fff;
    outline: none;
    border-width: 0;
    border-radius: 4px;
    font-size: 12px;
    margin-left: 10px;
    &:nth-child(1) {
      margin-left: 0;
    }
    &:nth-child(2) {
      background: #ebf5ff;
      color: #20a0ff;
      border: 1px solid #abd5ff;
    }
  }
}
.menu-list {
  padding: 20px 0;
  box-sizing: border-box;
  .left {
    button {
      padding: 0 20px;
      height: 28px;
      background: #20a0ff;
      color: #fff;
      outline: none;
      border-width: 0;
      border-radius: 4px;
      font-size: 12px;
      margin-left: 10px;
      &:nth-child(1) {
        margin-left: 0;
      }
    }
    button[disabled] {
      padding: 0 20px;
      height: 28px;
      background: #c1e0ff;
      color: #fafbff;
      outline: none;
      border-width: 0;
      border-radius: 4px;
      font-size: 12px;
    }
  }
}
.el-date-editor.el-input {
  width: 193px;
}
.menu-list {
  width: 100%;
  display: flex;
  justify-content: space-between;
}
.statistics {
  div {
    margin-right: 40px;
    font-size: 16px;
  }
}
.head-title2 {
  display: flex;
  justify-content: space-between;
}
</style>